using System;
using Baula.Testing.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Baula.TextGen.ActiveTemplating.Tests
{
    [TestClass]
    public class FormsContextTests
    {
        private IFormsContext _forms;

        [TestInitialize]
        public void TestInitialize()
        {
            _forms = new FormsContext
                     {
                         new FormInfo("Form1"),
                         new FormInfo("Form2"),
                         new FormInfo("Form3")
                     };
        }

        [TestMethod]
        public void CanIndexWithInteger()
        {
#pragma warning disable 168
            var dummy = _forms[0];
#pragma warning restore 168
            // Assert.Pass()
        }

        [TestMethod]
        public void CanIndexWithFormName()
        {
#pragma warning disable 168
            var dummy = _forms["Form1"];
#pragma warning restore 168
            // Assert.Pass()
        }

        [TestMethod]
        public void IndexWithString_WithInvalidFormName_ThrowsException()
        {
            var exception = ExceptionAssert.Expect(
                () => _forms["ThisIsNotAValidFormName"]
                );
            
            Assert.IsInstanceOfType(exception, typeof(IndexOutOfRangeException));
        }
    }
}